package com.ipacs.abs4j.testcode.absSchema;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class ComponentDefinitionParser extends AbstractAbsBeanDefinitionParser{
	
	
	protected Class<ComponentProcessor> getBeanClass(Element element){
		return ComponentProcessor.class	;
		
	}
	
	protected void doParse(Element element,ParserContext ctx,BeanDefinitionBuilder builder) {
				
		System.out.println("begin to parse component..");
		NodeList nl = element.getElementsByTagName("bean") ;
		
		BeanDefinitionParserDelegate pd = new BeanDefinitionParserDelegate(ctx.getReaderContext()) ;
		BeanDefinitionHolder bh= pd.parseBeanDefinitionElement((Element)nl.item(0), builder.getBeanDefinition()) ;
		
		this.commonParse(element, builder);
		
		builder.addPropertyValue("baseService", bh.getBeanDefinition()) ;
		System.out.println("component class" +bh.getBeanDefinition().getClass() );
				
	}

}
